﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Web.master" AutoEventWireup="true"
    CodeFile="PowerManage.aspx.cs" Inherits="Systems_PowerManage" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <script src="../Scripts/menuTree.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript" src="PowerTree.aspx"></script>
    <script language="javascript" type="text/javascript">
        var role;
        function doTest() {
            role = $("select[id$='lbxAvailableRoles']").val();
            if (role != null) {
                PageMethods.getMenuData(role, function (res) {
                    for (var i = 0; i < ctl01.elements.length; i++) {
                        var e = ctl01.elements[i];
                        if (e.id.toString().substring(0, 8) == "checkbox") {
                            e.checked = false;
                            demo.oncheck(e.id.substring(8, e.id.length));
                        }
                    }
                    var p = res;
                    if (p != "") {
                        arrIDList = p.toString().split(",");
                        for (i = 0; i < arrIDList.length; i++) {
                            if ($("#checkbox" + arrIDList[i]).length) {
                                $("#checkbox" + arrIDList[i]).attr("checked", true);
                                demo.oncheck(arrIDList[i]);
                            }
                        }
                    }
                    $("#BtnSave").attr('class', 'btn');
                    $("#BtnSave").removeAttr("disabled");
                });
            }
        }
        function fSelect() {
            if (role != null && role != '') {
                var chk = demo.Nodes;
                var zf_dw = "";
                var strRolesName = "";

                for (var o in chk) {
                    if (chk[o].checked) {
                        zf_dw = zf_dw + chk[o].ID + ',';
                        chk[o].checked = false;
                    }
                }
                PageMethods.saveData(zf_dw, role, function () { alert("保存成功！"); });
            }
            else {
                alert("保存失败，请重试！");
            }
        }
    </script>
</asp:Content>
<asp:Content ID="aspnetForm" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" />
    <asp:HiddenField ID="HidSystemType" runat="server" />
    <div class="filter-from" style="width: 700px; height: 520px; overflow: auto;">
        <table border="0">
            <tr>
                <td colspan="3" align="center">
                    <asp:Label ID="LabelTitle" runat="server"></asp:Label>
                </td>
            </tr>
            <tr>
                <td align="center" width="200px">
                    <asp:Label ID="lblRoleInfoText" runat="server"></asp:Label>
                    <asp:ListBox ID="lbxAvailableRoles" Rows="10" runat="server" Width="90%" DataTextField="RoleName"
                        DataValueField="RoleName"></asp:ListBox>
                </td>
                <td align="center" width="200px">
                    &nbsp;<input id="BtnSave" type="button" class="btn-disabled" value="确定" disabled=disabled onclick="fSelect()" />&nbsp;
                </td>
                <td align="left">
                    <table>
                        <tr>
                            <td align="left">
                                <script language="JavaScript">
                                <!--
                                    demo.setCheckbox(true);
                                    demo.setName = "demoTree";
                                    document.write(demo);
                                -->
                                </script>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </div>
</asp:Content>
